import axios from "@/api";

// let authUrlPrefix = "http://localhost:9090";
// let authUrlPrefix = "";
// let leaveUrlPrefix = "http://localhost:9091";
// let leaveUrlPrefix = "";
// let commodityUrlPrefix = "http://localhost:9092";
// let commodityUrlPrefix = "";

export function logoutApi() {
  return axios({
    method: "get",
    url: "/logout",
  });
}
export function loginApi(username, password) {
  return axios({
    method: "post",
    url: "/login",
    data: `username=${username}&password=${password}`,
  });
}
export function roleRoutesApi() {
  return axios({
    method: "get",
    url: "/safety/secure/roleRoutes",
  });
}
export function registerApi(regForm) {
  return axios({
    method: "post",
    url: "/safety/secure/regAbout/register",
    data: regForm,
  });
}
export function usernameExistApi(username) {
  return axios({
    method: "get",
    url: `/safety/secure/regAbout/usernameExits?username=${username}`,
  });
}

//业务枚举等初始化信息
export function ApplyStatesApi() {
  return axios({
    method: "get",
    url: "/leave/basic/ApplyStates",
  });
}
export function AuditStatesApi() {
  return axios({
    method: "get",
    url: "/leave/basic/AuditStates",
  });
}
export function LeaveTypesApi() {
  return axios({
    method: "get",
    url: "/leave/basic/LeaveTypes",
  });
}
export function leaveQueryApplyApi(searchForm) {
  return axios({
    method: "post",
    url: "/leave/about/query/apply",
    data: searchForm,
  });
}
export function leaveInsertApi(insertApply) {
  return axios({
    method: "post",
    url: "/leave/about",
    data: insertApply,
  });
}
function leaveModifyApi(modifyApply) {
  return axios({
    method: "put",
    url: "/leave/about/modify",
    data: modifyApply,
  });
}
function leaveGetApplyApi(id) {
  return axios({
    method: "get",
    url: `/leave/about/apply/${id}`,
  });
}
function leaveSubmitApi(id) {
  return axios({
    method: "put",
    url: `/leave/about/submit/${id}`,
  });
}
function leaveConfirmApi(id) {
  return axios({
    method: "put",
    url: `/leave/about/confirm/${id}`,
  });
}
function leaveGetAuditApi(id) {
  return axios({
    method: "get",
    url: `/leave/about/audit/${id}`,
  });
}
function leaveQueryAuditApi(searchForm) {
  return axios({
    method: "post",
    url: "/leave/about/query/audit",
    data: searchForm,
  });
}
function leaveAuditSucceedApi(modifyAudit) {
  return axios({
    method: "put",
    url: "/leave/about/audit/succeed",
    data: modifyAudit,
  });
}
function leaveAuditFailedApi(modifyAudit) {
  return axios({
    method: "put",
    url: "/leave/about/audit/failed",
    data: modifyAudit,
  });
}
export const safetyModuleApi = {
  logoutApi,
  loginApi,
  roleRoutesApi,
  registerApi,
  usernameExistApi,
};
export const leaveModuleApi = {
  ApplyStatesApi,
  AuditStatesApi,
  LeaveTypesApi,

  leaveGetApplyApi,
  leaveQueryApplyApi,

  leaveGetAuditApi,
  leaveQueryAuditApi,

  leaveInsertApi,
  leaveModifyApi,
  leaveSubmitApi,
  leaveAuditSucceedApi,
  leaveAuditFailedApi,
  leaveConfirmApi,
};
function cmEntityQueryApi(searchForm) {
  return axios({
    method: "post",
    url: "/commodity/commodityEntity/query",
    data: searchForm,
  });
}

function cmEntityInsertApi(cmEntity) {
  return axios({
    method: "post",
    url: "/commodity/commodityEntity/",
    data: cmEntity,
  });
}
//http://localhost:9092/commodity/commodityEntity/find?nameOrCode=%E5%B
function cmEntityFindApi(nameOrCode) {
  return axios({
    method: "get",
    url: `/commodity/commodityEntity/find?nameOrCode=${nameOrCode}`,
  });
}
function distributorQueryApi(searchForm) {
  return axios({
    method: "post",
    url: "/commodity/distributor/query",
    data: searchForm,
  });
}
function distributorInsertApi(entity) {
  return axios({
    method: "post",
    url: "/commodity/distributor/",
    data: entity,
  });
}
function distributorFindApi(nameOrCode) {
  //  http://localhost:9092/commodity/distributor/find?nameOrCode=%E5%B1%B1%E8%A5%BF
  return axios({
    method: "get",
    url: "/commodity/distributor/find?nameOrCode=" + nameOrCode,
  });
}
function commodityTypesApi() {
  return axios({
    method: "get",
    url: "/commodity/CommodityType/all",
  });
}
function storageQueryApi(searchForm) {
  return axios({
    method: "post",
    url: "/commodity/storage/query",
    data: searchForm,
  });
}
export const commodityModuleApi = {
  cmEntityQueryApi,
  cmEntityInsertApi,
  cmEntityFindApi,
  distributorQueryApi,
  distributorInsertApi,
  distributorFindApi,
  commodityTypesApi,
  storageQueryApi,
};
function purchaseInsertApi(bill) {
  //  POST
  // /bill/purchase/insert
  return axios({
    method: "post",
    url: "/bill/purchase/insert",
    data: bill,
  });
}

export const billModuleApi = {
  purchaseInsertApi,
};
